package com.appwoo.txtws.activity;

import android.app.ProgressDialog;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.Editable;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.TextView;
import com.appwoo.android.activity.BaseActivity;
import com.appwoo.android.exception.NotFoundNetWorkException;
import com.appwoo.android.exception.TimeOutException;
import com.appwoo.txtws.bean.StateBean;
import com.appwoo.txtws.component.Logger;
import com.appwoo.txtws.component.MD5Builder;
import com.appwoo.txtws.component.RqSP;
import com.appwoo.txtws.service.PasswordService;
import java.io.IOException;
import org.xmlpull.v1.XmlPullParserException;

public class UserInfoEditPasswordActivity extends BaseActivity
{
  private EditText edit_userinfo_oldpassword;
  private SharedPreferences.Editor editor;
  private String equipName = "";
  private PasswordService f_passwordService;
  private String f_userName = null;
  private String oldpwd;
  private RqSP rp;
  private SharedPreferences sp;
  private EditText v_edit_changepass_cofpassword;
  private EditText v_edit_changepass_newpassword;
  private ProgressDialog v_progressDialog;
  private TextView v_textview_changepassword_change;
  private TextView v_textview_userinfo_back;

  private void addBackLisener()
  {
    this.v_textview_userinfo_back.setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        UserInfoEditPasswordActivity.this.backAcitvity(UserInfoEditPasswordActivity.this);
      }
    });
  }

  private void addChanfPasswordLisener()
  {
    this.v_textview_changepassword_change.setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        String str1 = UserInfoEditPasswordActivity.this.edit_userinfo_oldpassword.getText().toString();
        String str2 = UserInfoEditPasswordActivity.this.v_edit_changepass_newpassword.getText().toString();
        String str3 = UserInfoEditPasswordActivity.this.v_edit_changepass_cofpassword.getText().toString();
        if (UserInfoEditPasswordActivity.this.check(str2, str3, str1))
          new UserInfoEditPasswordActivity.changePasswordAsyncTask(UserInfoEditPasswordActivity.this).execute(new String[] { "change", str2 });
      }
    });
  }

  private void addListener()
  {
    addBackLisener();
    addChanfPasswordLisener();
  }

  private void bgShowchangepass(String paramString)
  {
    if (paramString != null)
    {
      alertMessage(paramString);
      if (paramString.equals("成功"))
      {
        String str = this.v_edit_changepass_newpassword.getText().toString();
        new RqSP().setLgPwd(MD5Builder.getMD5(str), this);
        this.edit_userinfo_oldpassword.setText("");
        this.v_edit_changepass_newpassword.setText("");
        this.v_edit_changepass_cofpassword.setText("");
        backAcitvity(this);
      }
    }
  }

  private String bgchangePass(String paramString1, String paramString2)
  {
    Logger.i("TXTW", "f_userName==" + this.f_userName);
    Logger.i("TXTW", "equipName==" + paramString1);
    Logger.i("TXTW", "newpass==" + paramString2);
    try
    {
      String str = this.f_passwordService.changePassword(this.f_userName, paramString1, paramString2, this).getDesc();
      return str;
    }
    catch (IOException localIOException)
    {
      return getString(2131427525);
    }
    catch (XmlPullParserException localXmlPullParserException)
    {
      return getString(2131427525);
    }
    catch (TimeOutException localTimeOutException)
    {
      return getString(2131427525);
    }
    catch (NotFoundNetWorkException localNotFoundNetWorkException)
    {
      localNotFoundNetWorkException.getClass();
    }
    return "没有连接到网络";
  }

  private boolean check(String paramString1, String paramString2, String paramString3)
  {
    boolean bool = true;
    if (paramString3.equals(""))
    {
      alertMessage(getString(2131427991));
      bool = false;
    }
    do
    {
      return bool;
      if (!this.oldpwd.equals(MD5Builder.getMD5(paramString3)))
      {
        alertMessage(getString(2131427992));
        return false;
      }
      if (paramString1.equals(""))
      {
        alertMessage(getString(2131427993));
        return false;
      }
      if ((paramString1.length() < 6) || (paramString1.length() > 16) || (paramString2.length() < 6) || (paramString2.length() > 16))
      {
        alertMessage(getString(2131427994));
        return false;
      }
      if (this.oldpwd.equals(paramString1))
      {
        alertMessage(getString(2131427995));
        return false;
      }
    }
    while (paramString2.equals(paramString1));
    alertMessage(getString(2131427996));
    return false;
  }

  private void createOrShowDialog()
  {
    if ((this.v_progressDialog == null) || (!this.v_progressDialog.isShowing()))
    {
      this.v_progressDialog = new ProgressDialog(this);
      this.v_progressDialog.setMessage(getString(2131427516));
      this.v_progressDialog.setCancelable(true);
      this.v_progressDialog.show();
    }
  }

  private void initView()
  {
    this.sp = getSharedPreferences("firstLogin", 0);
    this.editor = this.sp.edit();
    this.f_passwordService = new PasswordService();
    this.v_textview_userinfo_back = ((TextView)findViewById(2131493608));
    this.v_textview_changepassword_change = ((TextView)findViewById(2131493618));
    this.v_edit_changepass_newpassword = ((EditText)findViewById(2131493614));
    this.v_edit_changepass_cofpassword = ((EditText)findViewById(2131493617));
    this.edit_userinfo_oldpassword = ((EditText)findViewById(2131493611));
    this.equipName = getSharedPreferences("equipname", 0).getString("equipname", null);
    this.rp = new RqSP();
    this.equipName = this.rp.getLgDevId(this);
    this.f_userName = this.rp.getLgAccount(this);
    this.oldpwd = this.rp.getLgPwd(this);
  }

  private void showView()
  {
    if ((this.f_userName == null) || (this.f_userName.equals("")))
    {
      alertMessage(getString(2131427990));
      backAcitvity(this);
    }
  }

  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(2130903224);
    initView();
    addListener();
    showView();
  }

  public class changePasswordAsyncTask extends AsyncTask<String, Integer, String>
  {
    private String method = "";

    public changePasswordAsyncTask()
    {
    }

    protected String doInBackground(String[] paramArrayOfString)
    {
      this.method = paramArrayOfString[0];
      if (this.method.equals("change"))
      {
        String str = paramArrayOfString[1];
        return UserInfoEditPasswordActivity.this.bgchangePass(UserInfoEditPasswordActivity.this.f_userName, str);
      }
      return "";
    }

    protected void onPostExecute(String paramString)
    {
      if (this.method.equals("change"))
        UserInfoEditPasswordActivity.this.bgShowchangepass(paramString);
      UserInfoEditPasswordActivity.this.v_progressDialog.dismiss();
    }

    protected void onPreExecute()
    {
      UserInfoEditPasswordActivity.this.createOrShowDialog();
    }
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.activity.UserInfoEditPasswordActivity
 * JD-Core Version:    0.6.2
 */